#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
typedef long long LL;

const int MAXN = 42;

int len[MAXN];
bool f[1602][1602];


bool isTriangle(int a, int b, int c) {
  return (a + b > c || a + c > b || b + c > a);
}

// 16s^2, 用海伦公式算
LL getArea(int a, int b, int c) {
  return 1LL * (a + b + c) * (a + b - c) * (a + c - b) * (b + c - a);
}

int main() {
  int n;
  cin >> n;
  int sum = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> len[i];
    sum = sum + len[i];  // 累加，记下所有火柴棒总长度
  }

  memset(f, 0, sizeof(f));
  f[0][0] = true;

  int v = sum / 2;
  for (int i = 1; i <= n; i++)
    for (int a = v; a >= 0; a--)
      for (int b = v; b >= 0; b--) {
        if (a >= len[i] && f[a - len[i]][b] ||
            (b >= len[i] && f[a][b - len[i]])) // 注意数组下标>=0
          f[a][b] = true;
        // 如果前面a-len[i]，现在第i根火柴棒加入，就可以拼成a
        // 如果前面b-len[i]可以拼成，现在第i根火柴棒加入，就可以拼成 b。
      }
  LL ans = -1;
  for (int a = 1; a <= v; a++) {
    for (int b = 1; b <= v; b++) {
      int c = sum - a - b;
      if (f[a][b] && isTriangle(a, b, c)) {
        ans = max(ans, getArea(a, b, c));
      }
    }
  }
  cout << ans;
  return 0;
}
